package code.google.model.player.states;

import code.google.model.util.interfaces.ISong;

public class StateManager {
	
	private IdleStreamState idleStreamState;
	private PlayingStreamState playingStreamState;
	private PlayingLocalState playingLocalState;
	private PausingStreamState pausingStreamState;
	private PausingLocalState pausingLocalState;
	private PreparingStreamState preparingStreamState;
	private PreparingLocalState preparingLocalState;
	private IdleLocalState idleLocalState;
	private StartState startState;
	
	private State currentState;
	
	void setCurrentState(State currentState) {
		this.currentState = currentState;
	}

	public StateManager(){
		startState = new StartState(this);
		idleStreamState = new IdleStreamState(this);
		idleLocalState = new IdleLocalState(this);
		playingLocalState = new PlayingLocalState(this);
		playingStreamState = new PlayingStreamState(this);
		pausingLocalState = new PausingLocalState(this);
		pausingStreamState = new PausingStreamState(this);
		preparingLocalState = new PreparingLocalState(this);
		preparingStreamState = new PreparingStreamState(this);
		
		currentState = startState;
		
	}
	
	PreparingStreamState getPreparingStreamState() {
		return preparingStreamState;
	}

	PreparingLocalState getPreparingLocalState() {
		return preparingLocalState;
	}

	IdleStreamState getIdleStreamState() {
		return idleStreamState;
	}
	
	PlayingStreamState getPlayingStreamState() {
		return playingStreamState;
	}
	
	PlayingLocalState getPlayingLocalState() {
		return playingLocalState;
	}
	
	PausingStreamState getPausingStreamState() {
		return pausingStreamState;
	}
	
	PausingLocalState getPausingLocalState() {
		return pausingLocalState;
	}

	State getCurrentState(){
		return currentState;
	}

	State getIdleLocalState() {
		return idleLocalState;
	}

	State getStartState() {
		return startState;
	}
	
	public boolean play(ISong song){
		return currentState.play(song);
	}
	
	public boolean play(){
		return currentState.play();
	}
	
	public boolean pause(){
		return currentState.pause();
	}
	
	public boolean seekTo(int position){
		return currentState.seekTo(position);
	}
	
	public ISong getCurrentSong(){
		return currentState.getCurrentSong();
	}

	public void reset() {
		currentState.destroy();
	}

	public boolean isPlaying() {
		return currentState.isPlaying();
	}
}
